home *** CD-ROM | disk | FTP | other *** search
/ Freelog 125 / Freelog_MarsAvril2015_No125.iso / Musique / Quod Libet / quodlibet-3.3.0-portable.exe / quodlibet-3.3.0-portable / data / bin / random.pyc (.txt) < prev    next >
Python Compiled Bytecode  |  2014-12-31  |  25KB  |  728 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.7)
  3.  
  4. '''Random variable generators.
  5.  
  6.     integers
  7.     --------
  8.            uniform within range
  9.  
  10.     sequences
  11.     ---------
  12.            pick random element
  13.            pick random sample
  14.            generate random permutation
  15.  
  16.     distributions on the real line:
  17.     ------------------------------
  18.            uniform
  19.            triangular
  20.            normal (Gaussian)
  21.            lognormal
  22.            negative exponential
  23.            gamma
  24.            beta
  25.            pareto
  26.            Weibull
  27.  
  28.     distributions on the circle (angles 0 to 2pi)
  29.     ---------------------------------------------
  30.            circular uniform
  31.            von Mises
  32.  
  33. General notes on the underlying Mersenne Twister core generator:
  34.  
  35. * The period is 2**19937-1.
  36. * It is one of the most extensively tested generators in existence.
  37. * Without a direct way to compute N steps forward, the semantics of
  38.   jumpahead(n) are weakened to simply jump to another distant state and rely
  39.   on the large period to avoid overlapping sequences.
  40. * The random() method is implemented in C, executes in a single Python step,
  41.   and is, therefore, threadsafe.
  42.  
  43. '''
  44. from __future__ import division
  45. from warnings import warn as _warn
  46. from types import MethodType as _MethodType, BuiltinMethodType as _BuiltinMethodType
  47. from math import log as _log, exp as _exp, pi as _pi, e as _e, ceil as _ceil
  48. from math import sqrt as _sqrt, acos as _acos, cos as _cos, sin as _sin
  49. from os import urandom as _urandom
  50. from binascii import hexlify as _hexlify
  51. import hashlib as _hashlib
  52. __all__ = [
  53.     'Random',
  54.     'seed',
  55.     'random',
  56.     'uniform',
  57.     'randint',
  58.     'choice',
  59.     'sample',
  60.     'randrange',
  61.     'shuffle',
  62.     'normalvariate',
  63.     'lognormvariate',
  64.     'expovariate',
  65.     'vonmisesvariate',
  66.     'gammavariate',
  67.     'triangular',
  68.     'gauss',
  69.     'betavariate',
  70.     'paretovariate',
  71.     'weibullvariate',
  72.     'getstate',
  73.     'setstate',
  74.     'jumpahead',
  75.     'WichmannHill',
  76.     'getrandbits',
  77.     'SystemRandom']
  78. NV_MAGICCONST = 4 * _exp(-0.5) / _sqrt(2)
  79. TWOPI = 2 * _pi
  80. LOG4 = _log(4)
  81. SG_MAGICCONST = 1 + _log(4.5)
  82. BPF = 53
  83. RECIP_BPF = 2 ** (-BPF)
  84. import _random
  85.  
  86. class Random(_random.Random):
  87.     """Random number generator base class used by bound module functions.
  88.  
  89.     Used to instantiate instances of Random to get generators that don't
  90.     share state.  Especially useful for multi-threaded programs, creating
  91.     a different instance of Random for each thread, and using the jumpahead()
  92.     method to ensure that the generated sequences seen by each thread don't
  93.     overlap.
  94.  
  95.     Class Random can also be subclassed if you want to use a different basic
  96.     generator of your own devising: in that case, override the following
  97.     methods: random(), seed(), getstate(), setstate() and jumpahead().
  98.     Optionally, implement a getrandbits() method so that randrange() can cover
  99.     arbitrarily large ranges.
  100.  
  101.     """
  102.     VERSION = 3
  103.     
  104.     def __init__(self, x = None):
  105.         '''Initialize an instance.
  106.  
  107.         Optional argument x controls seeding, as for Random.seed().
  108.         '''
  109.         self.seed(x)
  110.         self.gauss_next = None
  111.  
  112.     
  113.     def seed(self, a = None):
  114.         '''Initialize internal state from hashable object.
  115.  
  116.         None or no argument seeds from current time or from an operating
  117.         system specific randomness source if available.
  118.  
  119.         If a is not None or an int or long, hash(a) is used instead.
  120.         '''
  121.         if a is None:
  122.             
  123.             try:
  124.                 a = long(_hexlify(_urandom(16)), 16)
  125.             except NotImplementedError:
  126.                 import time as time
  127.                 a = long(time.time() * 256)
  128.             
  129.  
  130.         super(Random, self).seed(a)
  131.         self.gauss_next = None
  132.  
  133.     
  134.     def getstate(self):
  135.         '''Return internal state; can be passed to setstate() later.'''
  136.         return (self.VERSION, super(Random, self).getstate(), self.gauss_next)
  137.  
  138.     
  139.     def setstate(self, state):
  140.         '''Restore internal state from object returned by getstate().'''
  141.         version = state[0]
  142.         if version == 3:
  143.             (version, internalstate, self.gauss_next) = state
  144.             super(Random, self).setstate(internalstate)
  145.         elif version == 2:
  146.             (version, internalstate, self.gauss_next) = state
  147.             
  148.             try:
  149.                 internalstate = tuple((lambda .0: pass)(internalstate))
  150.             except ValueError:
  151.                 e = None
  152.                 raise TypeError, e
  153.  
  154.             super(Random, self).setstate(internalstate)
  155.         else:
  156.             raise ValueError('state with version %s passed to Random.setstate() of version %s' % (version, self.VERSION))
  157.  
  158.     
  159.     def jumpahead(self, n):
  160.         '''Change the internal state to one that is likely far away
  161.         from the current state.  This method will not be in Py3.x,
  162.         so it is better to simply reseed.
  163.         '''
  164.         s = repr(n) + repr(self.getstate())
  165.         n = int(_hashlib.new('sha512', s).hexdigest(), 16)
  166.         super(Random, self).jumpahead(n)
  167.  
  168.     
  169.     def __getstate__(self):
  170.         return self.getstate()
  171.  
  172.     
  173.     def __setstate__(self, state):
  174.         self.setstate(state)
  175.  
  176.     
  177.     def __reduce__(self):
  178.         return (self.__class__, (), self.getstate())
  179.  
  180.     
  181.     def randrange(self, start, stop = None, step = 1, _int = int, _maxwidth = 0x1L << BPF):
  182.         '''Choose a random item from range(start, stop[, step]).
  183.  
  184.         This fixes the problem with randint() which includes the
  185.         endpoint; in Python this is usually not what you want.
  186.  
  187.         '''
  188.         istart = _int(start)
  189.         if istart != start:
  190.             raise ValueError, 'non-integer arg 1 for randrange()'
  191.         if stop is None:
  192.             if istart > 0:
  193.                 if istart >= _maxwidth:
  194.                     return self._randbelow(istart)
  195.                 return None(self.random() * istart)
  196.             raise None, 'empty range for randrange()'
  197.         istop = _int(stop)
  198.         if istop != stop:
  199.             raise ValueError, 'non-integer stop for randrange()'
  200.         width = istop - istart
  201.         if step == 1 and width > 0:
  202.             if width >= _maxwidth:
  203.                 return _int(istart + self._randbelow(width))
  204.             return None(istart + _int(self.random() * width))
  205.         if None == 1:
  206.             raise ValueError, 'empty range for randrange() (%d,%d, %d)' % (istart, istop, width)
  207.         istep = _int(step)
  208.         if istep != step:
  209.             raise ValueError, 'non-integer step for randrange()'
  210.         if istep > 0:
  211.             n = (width + istep - 1) // istep
  212.         elif istep < 0:
  213.             n = (width + istep + 1) // istep
  214.         else:
  215.             raise ValueError, 'zero step for randrange()'
  216.         if None <= 0:
  217.             raise ValueError, 'empty range for randrange()'
  218.         if n >= _maxwidth:
  219.             return istart + istep * self._randbelow(n)
  220.         return None + istep * _int(self.random() * n)
  221.  
  222.     
  223.     def randint(self, a, b):
  224.         '''Return random integer in range [a, b], including both end points.
  225.         '''
  226.         return self.randrange(a, b + 1)
  227.  
  228.     
  229.     def _randbelow(self, n, _log = _log, _int = int, _maxwidth = 0x1L << BPF, _Method = _MethodType, _BuiltinMethod = _BuiltinMethodType):
  230.         '''Return a random int in the range [0,n)
  231.  
  232.         Handles the case where n has more bits than returned
  233.         by a single call to the underlying generator.
  234.         '''
  235.         
  236.         try:
  237.             getrandbits = self.getrandbits
  238.         except AttributeError:
  239.             pass
  240.  
  241.         if type(self.random) is _BuiltinMethod or type(getrandbits) is _Method:
  242.             k = _int(1.00001 + _log(n - 1, 2))
  243.             r = getrandbits(k)
  244.             while r >= n:
  245.                 r = getrandbits(k)
  246.             return r
  247.         if None >= _maxwidth:
  248.             _warn('Underlying random() generator does not supply \nenough bits to choose from a population range this large')
  249.         return _int(self.random() * n)
  250.  
  251.     
  252.     def choice(self, seq):
  253.         '''Choose a random element from a non-empty sequence.'''
  254.         return seq[int(self.random() * len(seq))]
  255.  
  256.     
  257.     def shuffle(self, x, random = None):
  258.         '''x, random=random.random -> shuffle list x in place; return None.
  259.  
  260.         Optional arg random is a 0-argument function returning a random
  261.         float in [0.0, 1.0); by default, the standard random.random.
  262.  
  263.         '''
  264.         if random is None:
  265.             random = self.random
  266.         _int = int
  267.         for i in reversed(xrange(1, len(x))):
  268.             j = _int(random() * (i + 1))
  269.             x[i] = x[j]
  270.             x[j] = x[i]
  271.         
  272.  
  273.     
  274.     def sample(self, population, k):
  275.         '''Chooses k unique random elements from a population sequence.
  276.  
  277.         Returns a new list containing elements from the population while
  278.         leaving the original population unchanged.  The resulting list is
  279.         in selection order so that all sub-slices will also be valid random
  280.         samples.  This allows raffle winners (the sample) to be partitioned
  281.         into grand prize and second place winners (the subslices).
  282.  
  283.         Members of the population need not be hashable or unique.  If the
  284.         population contains repeats, then each occurrence is a possible
  285.         selection in the sample.
  286.  
  287.         To choose a sample in a range of integers, use xrange as an argument.
  288.         This is especially fast and space efficient for sampling from a
  289.         large population:   sample(xrange(10000000), 60)
  290.         '''
  291.         n = len(population)
  292.         if k <= k:
  293.             pass
  294.         elif not k <= n:
  295.             raise ValueError('sample larger than population')
  296.         random = self.random
  297.         _int = int
  298.         result = [
  299.             None] * k
  300.         setsize = 21
  301.         if k > 5:
  302.             setsize += 4 ** _ceil(_log(k * 3, 4))
  303.         return result
  304.  
  305.     
  306.     def uniform(self, a, b):
  307.         '''Get a random number in the range [a, b) or [a, b] depending on rounding.'''
  308.         return a + (b - a) * self.random()
  309.  
  310.     
  311.     def triangular(self, low = 0, high = 1, mode = None):
  312.         '''Triangular distribution.
  313.  
  314.         Continuous distribution bounded by given lower and upper limits,
  315.         and having a given mode value in-between.
  316.  
  317.         http://en.wikipedia.org/wiki/Triangular_distribution
  318.  
  319.         '''
  320.         u = self.random()
  321.         c = 0.5 if mode is None else (mode - low) / (high - low)
  322.         if u > c:
  323.             u = 1 - u
  324.             c = 1 - c
  325.             low = high
  326.             high = low
  327.         return low + (high - low) * (u * c) ** 0.5
  328.  
  329.     
  330.     def normalvariate(self, mu, sigma):
  331.         '''Normal distribution.
  332.  
  333.         mu is the mean, and sigma is the standard deviation.
  334.  
  335.         '''
  336.         random = self.random
  337.         while None:
  338.             u1 = random()
  339.             u2 = 1 - random()
  340.             z = NV_MAGICCONST * (u1 - 0.5) / u2
  341.             zz = z * z / 4
  342.             if zz <= -_log(u2):
  343.                 break
  344.                 continue
  345.                 continue
  346.                 return mu + z * sigma
  347.  
  348.     
  349.     def lognormvariate(self, mu, sigma):
  350.         """Log normal distribution.
  351.  
  352.         If you take the natural logarithm of this distribution, you'll get a
  353.         normal distribution with mean mu and standard deviation sigma.
  354.         mu can have any value, and sigma must be greater than zero.
  355.  
  356.         """
  357.         return _exp(self.normalvariate(mu, sigma))
  358.  
  359.     
  360.     def expovariate(self, lambd):
  361.         '''Exponential distribution.
  362.  
  363.         lambd is 1.0 divided by the desired mean.  It should be
  364.         nonzero.  (The parameter would be called "lambda", but that is
  365.         a reserved word in Python.)  Returned values range from 0 to
  366.         positive infinity if lambd is positive, and from negative
  367.         infinity to 0 if lambd is negative.
  368.  
  369.         '''
  370.         return -_log(1 - self.random()) / lambd
  371.  
  372.     
  373.     def vonmisesvariate(self, mu, kappa):
  374.         '''Circular data distribution.
  375.  
  376.         mu is the mean angle, expressed in radians between 0 and 2*pi, and
  377.         kappa is the concentration parameter, which must be greater than or
  378.         equal to zero.  If kappa is equal to zero, this distribution reduces
  379.         to a uniform random angle over the range 0 to 2*pi.
  380.  
  381.         '''
  382.         random = self.random
  383.         if kappa <= 1e-06:
  384.             return TWOPI * random()
  385.         s = None / kappa
  386.         r = s + _sqrt(1 + s * s)
  387.         while None:
  388.             u1 = random()
  389.             z = _cos(_pi * u1)
  390.             d = z / (r + z)
  391.             u2 = random()
  392.             if not u2 < 1 - d * d:
  393.                 if u2 <= (1 - d) * _exp(d):
  394.                     break
  395.                     continue
  396.                     continue
  397.                     q = 1 / r
  398.                     f = (q + z) / (1 + q * z)
  399.                     u3 = random()
  400.                     if u3 > 0.5:
  401.                         theta = (mu + _acos(f)) % TWOPI
  402.                     else:
  403.                         theta = (mu - _acos(f)) % TWOPI
  404.         return theta
  405.  
  406.     
  407.     def gammavariate(self, alpha, beta):
  408.         '''Gamma distribution.  Not the gamma function!
  409.  
  410.         Conditions on the parameters are alpha > 0 and beta > 0.
  411.  
  412.         The probability distribution function is:
  413.  
  414.                     x ** (alpha - 1) * math.exp(-x / beta)
  415.           pdf(x) =  --------------------------------------
  416.                       math.gamma(alpha) * beta ** alpha
  417.  
  418.         '''
  419.         if alpha <= 0 or beta <= 0:
  420.             raise ValueError, 'gammavariate: alpha and beta must be > 0.0'
  421.         random = self.random
  422.         if alpha > 1:
  423.             ainv = _sqrt(2 * alpha - 1)
  424.             bbb = alpha - LOG4
  425.             ccc = alpha + ainv
  426.             while None:
  427.                 u1 = random()
  428.                 if u1 < u1:
  429.                     pass
  430.                 elif not u1 < 1:
  431.                     continue
  432.                 u2 = 1 - random()
  433.                 v = _log(u1 / (1 - u1)) / ainv
  434.                 x = alpha * _exp(v)
  435.                 z = u1 * u1 * u2
  436.                 r = bbb + ccc * v - x
  437.                 while None:
  438.                     u = random()
  439.                     b = (_e + alpha) / _e
  440.                     p = b * u
  441.                     u1 = random()
  442.                     if p > 1 or u1 <= x ** (alpha - 1):
  443.                         break
  444.                     
  445.                     if u1 <= _exp(-x):
  446.                         break
  447.                         continue
  448.                         continue
  449.                         return x * beta
  450.                     return None if p <= 1 else 1e-07 if not r + SG_MAGICCONST - 4.5 * z >= 0 else u1 < 1
  451.  
  452.     
  453.     def gauss(self, mu, sigma):
  454.         '''Gaussian distribution.
  455.  
  456.         mu is the mean, and sigma is the standard deviation.  This is
  457.         slightly faster than the normalvariate() function.
  458.  
  459.         Not thread-safe without a lock around calls.
  460.  
  461.         '''
  462.         random = self.random
  463.         z = self.gauss_next
  464.         self.gauss_next = None
  465.         if z is None:
  466.             x2pi = random() * TWOPI
  467.             g2rad = _sqrt(-2 * _log(1 - random()))
  468.             z = _cos(x2pi) * g2rad
  469.             self.gauss_next = _sin(x2pi) * g2rad
  470.         return mu + z * sigma
  471.  
  472.     
  473.     def betavariate(self, alpha, beta):
  474.         '''Beta distribution.
  475.  
  476.         Conditions on the parameters are alpha > 0 and beta > 0.
  477.         Returned values range between 0 and 1.
  478.  
  479.         '''
  480.         y = self.gammavariate(alpha, 1)
  481.         if y == 0:
  482.             return 0
  483.         return None / (y + self.gammavariate(beta, 1))
  484.  
  485.     
  486.     def paretovariate(self, alpha):
  487.         '''Pareto distribution.  alpha is the shape parameter.'''
  488.         u = 1 - self.random()
  489.         return 1 / pow(u, 1 / alpha)
  490.  
  491.     
  492.     def weibullvariate(self, alpha, beta):
  493.         '''Weibull distribution.
  494.  
  495.         alpha is the scale parameter and beta is the shape parameter.
  496.  
  497.         '''
  498.         u = 1 - self.random()
  499.         return alpha * pow(-_log(u), 1 / beta)
  500.  
  501.  
  502.  
  503. class WichmannHill(Random):
  504.     VERSION = 1
  505.     
  506.     def seed(self, a = None):
  507.         '''Initialize internal state from hashable object.
  508.  
  509.         None or no argument seeds from current time or from an operating
  510.         system specific randomness source if available.
  511.  
  512.         If a is not None or an int or long, hash(a) is used instead.
  513.  
  514.         If a is an int or long, a is used directly.  Distinct values between
  515.         0 and 27814431486575L inclusive are guaranteed to yield distinct
  516.         internal states (this guarantee is specific to the default
  517.         Wichmann-Hill generator).
  518.         '''
  519.         if a is None:
  520.             
  521.             try:
  522.                 a = long(_hexlify(_urandom(16)), 16)
  523.             except NotImplementedError:
  524.                 import time
  525.                 a = long(time.time() * 256)
  526.             
  527.  
  528.         if not isinstance(a, (int, long)):
  529.             a = hash(a)
  530.         (a, x) = divmod(a, 30268)
  531.         (a, y) = divmod(a, 30306)
  532.         (a, z) = divmod(a, 30322)
  533.         self._seed = (int(x) + 1, int(y) + 1, int(z) + 1)
  534.         self.gauss_next = None
  535.  
  536.     
  537.     def random(self):
  538.         '''Get the next random number in the range [0.0, 1.0).'''
  539.         (x, y, z) = self._seed
  540.         x = 171 * x % 30269
  541.         y = 172 * y % 30307
  542.         z = 170 * z % 30323
  543.         self._seed = (x, y, z)
  544.         return (x / 30269 + y / 30307 + z / 30323) % 1
  545.  
  546.     
  547.     def getstate(self):
  548.         '''Return internal state; can be passed to setstate() later.'''
  549.         return (self.VERSION, self._seed, self.gauss_next)
  550.  
  551.     
  552.     def setstate(self, state):
  553.         '''Restore internal state from object returned by getstate().'''
  554.         version = state[0]
  555.         if version == 1:
  556.             (version, self._seed, self.gauss_next) = state
  557.         else:
  558.             raise ValueError('state with version %s passed to Random.setstate() of version %s' % (version, self.VERSION))
  559.  
  560.     
  561.     def jumpahead(self, n):
  562.         '''Act as if n calls to random() were made, but quickly.
  563.  
  564.         n is an int, greater than or equal to 0.
  565.  
  566.         Example use:  If you have 2 threads and know that each will
  567.         consume no more than a million random numbers, create two Random
  568.         objects r1 and r2, then do
  569.             r2.setstate(r1.getstate())
  570.             r2.jumpahead(1000000)
  571.         Then r1 and r2 will use guaranteed-disjoint segments of the full
  572.         period.
  573.         '''
  574.         if not n >= 0:
  575.             raise ValueError('n must be >= 0')
  576.         (x, y, z) = self._seed
  577.         x = int(x * pow(171, n, 30269)) % 30269
  578.         y = int(y * pow(172, n, 30307)) % 30307
  579.         z = int(z * pow(170, n, 30323)) % 30323
  580.         self._seed = (x, y, z)
  581.  
  582.     
  583.     def __whseed(self, x = 0, y = 0, z = 0):
  584.         '''Set the Wichmann-Hill seed from (x, y, z).
  585.  
  586.         These must be integers in the range [0, 256).
  587.         '''
  588.         if type(y) == type(y) and type(z) == type(z):
  589.             pass
  590.         elif not type(z) == int:
  591.             raise TypeError('seeds must be integers')
  592.         self._seed = (type(z) == int, x < 256 if x <= x else y < 256 if y <= y else 1, 1 if not y else 1)
  593.         self.gauss_next = None
  594.  
  595.     
  596.     def whseed(self, a = None):
  597.         """Seed from hashable object's hash code.
  598.  
  599.         None or no argument seeds from current time.  It is not guaranteed
  600.         that objects with distinct hash codes lead to distinct internal
  601.         states.
  602.  
  603.         This is obsolete, provided for compatibility with the seed routine
  604.         used prior to Python 2.1.  Use the .seed() method instead.
  605.         """
  606.         if a is None:
  607.             self._WichmannHill__whseed()
  608.             return None
  609.         a = None(a)
  610.         (a, x) = divmod(a, 256)
  611.         (a, y) = divmod(a, 256)
  612.         (a, z) = divmod(a, 256)
  613.         if not (x + a) % 256:
  614.             pass
  615.         x = 1
  616.         if not (y + a) % 256:
  617.             pass
  618.         y = 1
  619.         if not (z + a) % 256:
  620.             pass
  621.         z = 1
  622.         self._WichmannHill__whseed(x, y, z)
  623.  
  624.  
  625.  
  626. class SystemRandom(Random):
  627.     '''Alternate random number generator using sources provided
  628.     by the operating system (such as /dev/urandom on Unix or
  629.     CryptGenRandom on Windows).
  630.  
  631.      Not available on all systems (see os.urandom() for details).
  632.     '''
  633.     
  634.     def random(self):
  635.         '''Get the next random number in the range [0.0, 1.0).'''
  636.         return (long(_hexlify(_urandom(7)), 16) >> 3) * RECIP_BPF
  637.  
  638.     
  639.     def getrandbits(self, k):
  640.         '''getrandbits(k) -> x.  Generates a long int with k random bits.'''
  641.         if k <= 0:
  642.             raise ValueError('number of bits must be greater than zero')
  643.         if k != int(k):
  644.             raise TypeError('number of bits should be an integer')
  645.         bytes = (k + 7) // 8
  646.         x = long(_hexlify(_urandom(bytes)), 16)
  647.         return x >> bytes * 8 - k
  648.  
  649.     
  650.     def _stub(self, *args, **kwds):
  651.         '''Stub method.  Not used for a system random number generator.'''
  652.         pass
  653.  
  654.     seed = jumpahead = _stub
  655.     
  656.     def _notimplemented(self, *args, **kwds):
  657.         '''Method should not be called for a system random number generator.'''
  658.         raise NotImplementedError('System entropy source does not have state.')
  659.  
  660.     getstate = setstate = _notimplemented
  661.  
  662.  
  663. def _test_generator(n, func, args):
  664.     import time
  665.     print n, 'times', func.__name__
  666.     total = 0
  667.     sqsum = 0
  668.     smallest = 1e+10
  669.     largest = -1e+10
  670.     t0 = time.time()
  671.     for i in range(n):
  672.         x = func(*args)
  673.         total += x
  674.         sqsum = sqsum + x * x
  675.         smallest = min(x, smallest)
  676.         largest = max(x, largest)
  677.     
  678.     t1 = time.time()
  679.     print round(t1 - t0, 3), 'sec,',
  680.     avg = total / n
  681.     stddev = _sqrt(sqsum / n - avg * avg)
  682.     print 'avg %g, stddev %g, min %g, max %g' % (avg, stddev, smallest, largest)
  683.  
  684.  
  685. def _test(N = 2000):
  686.     _test_generator(N, random, ())
  687.     _test_generator(N, normalvariate, (0, 1))
  688.     _test_generator(N, lognormvariate, (0, 1))
  689.     _test_generator(N, vonmisesvariate, (0, 1))
  690.     _test_generator(N, gammavariate, (0.01, 1))
  691.     _test_generator(N, gammavariate, (0.1, 1))
  692.     _test_generator(N, gammavariate, (0.1, 2))
  693.     _test_generator(N, gammavariate, (0.5, 1))
  694.     _test_generator(N, gammavariate, (0.9, 1))
  695.     _test_generator(N, gammavariate, (1, 1))
  696.     _test_generator(N, gammavariate, (2, 1))
  697.     _test_generator(N, gammavariate, (20, 1))
  698.     _test_generator(N, gammavariate, (200, 1))
  699.     _test_generator(N, gauss, (0, 1))
  700.     _test_generator(N, betavariate, (3, 3))
  701.     _test_generator(N, triangular, (0, 1, 0.333333))
  702.  
  703. _inst = Random()
  704. seed = _inst.seed
  705. random = _inst.random
  706. uniform = _inst.uniform
  707. triangular = _inst.triangular
  708. randint = _inst.randint
  709. choice = _inst.choice
  710. randrange = _inst.randrange
  711. sample = _inst.sample
  712. shuffle = _inst.shuffle
  713. normalvariate = _inst.normalvariate
  714. lognormvariate = _inst.lognormvariate
  715. expovariate = _inst.expovariate
  716. vonmisesvariate = _inst.vonmisesvariate
  717. gammavariate = _inst.gammavariate
  718. gauss = _inst.gauss
  719. betavariate = _inst.betavariate
  720. paretovariate = _inst.paretovariate
  721. weibullvariate = _inst.weibullvariate
  722. getstate = _inst.getstate
  723. setstate = _inst.setstate
  724. jumpahead = _inst.jumpahead
  725. getrandbits = _inst.getrandbits
  726. if __name__ == '__main__':
  727.     _test()
  728.